﻿namespace ArrayDemo01
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var collection = new HelloCollection();
            foreach (string s in collection)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine("Hello, World!");

            Person[] persons = { new Person("Damon","Hill"),
                new Person("Niki","Lauda"),
                new Person("Ayrton","Senna"),
                new Person("Graham","Hill"),
            };
            Array.Sort(persons);
            //foreach (Person person in persons)
            //{
            //    Console.WriteLine(person);
            //}

            using (IEnumerator<Person> enumerator = ((IEnumerable<Person>)persons).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Person person = enumerator.Current;
                    Console.WriteLine(person);
                }
            }

            Console.ReadKey();
        }
    }

    class HelloCollection
    {
        public IEnumerator<string> GetEnumerator()
        {
            yield return "Hello";
            yield return "World";
        }
    }
}
